#ifndef H_SIMBAT_PLUGIN
#define H_SIMBAT_PLUGIN

#ifdef __cplusplus
extern "C" {
#endif

/* Read value from config.xml */
void *SimbatOpenConfig(char ErrStr[200 + 1]);
void SimbatConfigGetValue(void *Handle, const char *NodeName, const char *Tag, char *Result, int MaxLen);
void SimbatConfigGetPassword(void *Handle, const char *NodeName, const char *Tag, char *Result, int MaxLen);
void SimbatCloseConfig(void *Handle);

/* Db interface */

typedef int (*SIMBAT_PLUGIN_DB_CONNECT)(const char *System, char ErrStr[200 + 1]);
typedef int (*SIMBAT_PLUGIN_DB_COUNT_STATUS)(const char *System, int *Result, char ErrStr[200 + 1]);
typedef int (*SIMBAT_PLUGIN_DB_CLEAR_STATUS)(const char *System, char ErrStr[200 + 1]);
typedef int (*SIMBAT_PLUGIN_DB_WRITE_STATUS)(const char *System, int Idx, const char *RecType,
   const char Record[2000 + 1], char ErrStr[200 + 1]);
typedef int (*SIMBAT_PLUGIN_DB_READ_STATUS)(const char *System, int Idx, char *RecType,
   char Record[2000 + 1], char ErrStr[200 + 1]);
typedef int (*SIMBAT_PLUGIN_DB_REWRITE_STATUS)(const char *System, int Idx, const char *RecType,
   const char Record[2000 + 1], char ErrStr[200 + 1]);

/*
   ValueList format :
   StartTime | EndTime | Elapse | JobStatus
 */
typedef int (*SIMBAT_PLUGIN_DB_WRITE_HIS)(const char *System, const char *BatchSeq, const char *JobName,
   const char *ValueList, char ErrStr[200 + 1]);
typedef int (*SIMBAT_PLUGIN_DB_READ_STATISTIC)(const char *System, const char *BatchType, const char *JobName,
   int *n, int Elapse[10], char ErrStr[200 + 1]);
typedef int (*SIMBAT_PLUGIN_DB_WRITE_STATISTIC)(const char *System, const char *BatchType, const char *JobName,
   int n, int Elapse[10], char ErrStr[200 + 1]);

typedef struct
{
   SIMBAT_PLUGIN_DB_CONNECT             Connect;
   SIMBAT_PLUGIN_DB_COUNT_STATUS        CountStatus;
   SIMBAT_PLUGIN_DB_CLEAR_STATUS        ClearStatus;
   SIMBAT_PLUGIN_DB_WRITE_STATUS        WriteStatus;
   SIMBAT_PLUGIN_DB_READ_STATUS         ReadStatus;
   SIMBAT_PLUGIN_DB_REWRITE_STATUS      RewriteStatus;
   SIMBAT_PLUGIN_DB_WRITE_HIS           WriteHis;
   SIMBAT_PLUGIN_DB_READ_STATISTIC      ReadStatistic;
   SIMBAT_PLUGIN_DB_WRITE_STATISTIC     WriteStatistic;
} SimbatPluginDbInitArg;

typedef void (*SIMBAT_PLUGIN_DB_INIT)(SimbatPluginDbInitArg *Arg);

void SimbatPluginDbInit(SimbatPluginDbInitArg *Arg);

/* end of Db interface */

/* PushAlarm interface */

typedef int (*SIMBAT_PLUGIN_PUSH_ALARM)(const char *InfoStr, char ErrStr[200 + 1]);

int SimbatPluginPushAlarm(const char *InfoStr, char ErrStr[200 + 1]);

/* end of PushAlarm interface */

/* PushOutline interface */

typedef int (*SIMBAT_PLUGIN_PUSH_OUTLINE)(const char *InfoStrArray[], int Qty, char ErrStr[200 + 1]);

int SimbatPluginPushOutline(const char *InfoStrArray[], int Qty, char ErrStr[200 + 1]);

/* end of PushOutline interface */

/* Trigger interface */

typedef int (*SIMBAT_PLUGIN_TRIGGER)(const char *BatchDate, const char *Type, const char *Name, const char *Status);

int SimbatPluginTrigger(const char *BatchDate, const char *Type, const char *Name, const char *Status);

/* end of Trigger interface */

#ifdef __cplusplus
}
#endif

#endif
